﻿var meb = angular.module('lgqDirective', []);




//支付查询 刘国全 2015-7-8 12:01:44
meb.controller('ProductPaymentController', function ($scope, $http, Msg, paging) {

    //初始化模态窗
    $scope.md = Msg;
    //$scope.AuditingModel = false; //审核
    $scope.BackModel = false; //返款/退款
    $scope.BackDetailedModel = false; //返款详情

    //需要编辑的数据
    $scope.editorData = {};

    //获取支付方式
    getsortConfig = {
        method: 'GET',
        url: '/ProductPayment/GetStateInTablesModel?columnNote=1',
        data: {}
    }
    $http(getsortConfig).success(function (data) {
        $scope.paymentMethodAll = data.Data;
    }).error(function (data, status, headers, config) {
        $scope.md.show('提示', '数据获取失败');
    });

    //获取物流状态
    getsortConfig = {
        method: 'GET',
        url: '/ProductPayment/GetStateInTablesModel?columnNote=2',
        data: {}
    }
    $http(getsortConfig).success(function (data) {
        $scope.deliverState = data.Data;
        
    }).error(function (data, status, headers, config) {
        $scope.md.show('提示', '数据获取失败');
    });

    //退款返款状态
    getsortConfig = {
        method: 'GET',
        url: '/ProductPayment/GetStateInTablesModel?columnNote=3',
        data: {}
    }
    $http(getsortConfig).success(function (data) {
        $scope.refundState = data.Data;
        
    }).error(function (data, status, headers, config) {
        $scope.md.show('提示', '数据获取失败');
    });

    //就诊状态
    getsortConfig = {
        method: 'GET',
        url: '/ProductPayment/GetStateInTablesModel?columnNote=4',
        data: {}
    }
    $http(getsortConfig).success(function (data) {
        $scope.surgeryState = data.Data;
        
    }).error(function (data, status, headers, config) {
        $scope.md.show('提示', '数据获取失败');
    });

    //评价状态
    getsortConfig = {
        method: 'GET',
        url: '/ProductPayment/GetStateInTablesModel?columnNote=5',
        data: {}
    }
    $http(getsortConfig).success(function (data) {
        $scope.appraiseState = data.Data;

    }).error(function (data, status, headers, config) {
        $scope.md.show('提示', '数据获取失败');
    });

    //订单商品支付状态/PaymentState
    getsortConfig = {
        method: 'GET',
        url: '/ProductPayment/GetStateInTablesModel?columnNote=6',
        data: {}
    }
    $http(getsortConfig).success(function (data) {
        $scope.State = data.Data;

    }).error(function (data, status, headers, config) {
        $scope.md.show('提示', '数据获取失败');
    });

    //---------------------------------分页开始---------------------------------
    //初始化服务
    $scope.pagingModel = paging;

    //获取数据时的配置 查询条件
    $scope.getSourceConfig = {PageIndex: null, ProductOrderNumbe: "", Name: "", ProductNumber: "", PaymentMethod: 0, OrderStatus: null, CashbackAwaiting: null, StartCreateTime: "", EndCreateTime: "", CashbackOrRefund: 0, deliverState: 0, appraiseState: 0, refundState: 0 ,SurgeryState:0,State:0};
    //$scope.typeAllModel=null;
    init();
    //页面初始化
    function init() {
        //if ($scope.getSourceConfig.tableName != null) {
        //    $scope.getSourceConfig.columnNote = $scope.getSourceConfig.tableName.ColumnNote;
        //}
        //alert($scope.getSourceConfig.deliverState);
        //获取列表数据
        getsortConfig = {
            method: 'Post',
            url: '/ProductPayment/GetJson',
            data: $scope.getSourceConfig
        }
        $http(getsortConfig).success(function (data) {
            $scope.model = data;
            if ($scope.model.PageList.Page != null) {
                //初始化分页
                $scope.pagingModel.init($scope.model.PageList.Page.PageIndex, $scope.model.PageList.Page.PageCount, $scope.model.PageList.Page.PageSize, $scope.model.PageList.Page.RecordCount, function (index) {
                    $scope.getSourceConfig.PageIndex = index;
                    init();
                });
            } else {
                $scope.pagingModel.paging = false;
            }
            
        }).error(function (data, status, headers, config) {
            $scope.BackModel = false; 
            $scope.md.show('提示', '数据获取失败');
        });

    }
    //---------------------------------分页结束---------------------------------

    //搜索事件
    $scope.search = function () {
        init();
    }

    //审核数据
    //$scope.AuditingData = {};
    //返款数据
    $scope.BackData = {};
    $scope.titieStr = ""; //标题

    
    //返款/退款 界面
    $scope.BackModelMsg = function (productOrderId,productOrderNumber,productId, title) {
        $scope.titieStr = title;
        var cashbackOrRefundState = title == "返" ? 2 : 1;
        //获取数据 productOrderId, string productOrderNumber, Guid productId,int cashbackOrRefund
        var getsortConfig = {
            method: 'Post',
            url: '/ProductPayment/GetProductRefundCashbackModel',
            data: { productOrderId: productOrderId, productOrderNumber: productOrderNumber, productId: productId, cashbackOrRefund: cashbackOrRefundState }
        };
        $http(getsortConfig).success(function (data) {
            //console.log(data);
            if (data.ResultValue == 1) {
                $scope.BackModel = false;  //关闭当前模态窗口
                $scope.md.show('提示', '数据获取失败');
            } else {
                $scope.BackDetailedModel = false;
                $scope.BackModel = true;
                $scope.BackData = data.Data;
                //$scope.BackData.Reason = title + "款";
            }
        }).error(function (data, status, headers, config) {
            $scope.BackModel = false;  //关闭当前模态窗口
            $scope.md.show('提示', '数据获取失败');
        });

        //$scope.BackData ={ PaymentMethod: "支付宝支付", Money: 256.23, Desction: title, PaymentAccount: "13658020830" }
        $scope.md.okShow(title+"款", '', function () {
            //提价数据
            var getsortConfig = {
                method: 'Post',
                url: '/ProductPayment/ModifyModelState',
                data: { productOrderId: productOrderId, productOrderNumber: productOrderNumber, productId: productId, cashbackOrRefund: cashbackOrRefundState }
            };
            $http(getsortConfig).success(function (data) {
                console.log(data);
                if (data.ResultValue == 1) {
                    $scope.BackModel = false
                    $scope.md.show('提示', title + "款失败");
                } else {
                    $scope.BackModel = false;  //关闭当前模态窗口
                    $scope.md.show('提示', title + "款成功");
                    init();
                }
            }).error(function (data, status, headers, config) {
                $scope.BackModel = false;  //关闭当前模态窗口
                $scope.md.show('提示', title + "款失败");
            });
        });
    }


    //返款/退款 详情界面
    $scope.BackDetailedModelMsg = function (productOrderId, productOrderNumber, productId, title) {
       
        $scope.titieStr = title;
        var cashbackOrRefundState = title == "返" ? 2 : 1;
        //获取数据
        var getsortConfig = {
            method: 'Post',
            url: '/ProductPayment/GetProductRefundCashbackModel',
            data: { productOrderId: productOrderId, productOrderNumber: productOrderNumber, productId: productId, cashbackOrRefund: cashbackOrRefundState }
        };
        $http(getsortConfig).success(function (data) {
            //console.log(data);
            if (data.ResultValue == 1) {
                $scope.BackModel = false;  //关闭当前模态窗口
                $scope.BackDetailedModel = false;
                $scope.md.show('提示', '数据获取失败');
            } else {
                $scope.BackModel = false;
                $scope.BackDetailedModel = true;
                $scope.BackData = data.Data;
                //$scope.BackData.Reason = title + "款";
            }
        }).error(function (data, status, headers, config) {
            $scope.BackModel = false;  //关闭当前模态窗口
            $scope.BackDetailedModel = false;
            $scope.md.show('提示', '数据获取失败');
        });

        $scope.md.show(title + "款", '');

    }

    //支付change事件  编辑
    $scope.PaymentMethodChange = function () {
        var objM = $scope.PaymentMethod;
        if (objM != null) {
            $scope.getSourceConfig.PaymentMethod = objM.StateValue;
        }else{
            $scope.getSourceConfig.PaymentMethod = 0;
        }
        //alert($scope.getSourceConfig.PaymentMethod);
        init();
    }

    //物流change事件  编辑
    $scope.DeliverStateModelChange = function () {

        var objM = $scope.deliverStateModel;
        if (objM != null) {
            $scope.getSourceConfig.deliverState = objM.StateValue;
        } else {
            $scope.getSourceConfig.deliverState =0;
        }
        init();
    }
    //退款返款状态change事件  编辑
    $scope.RefundStateModelChange = function () {

        var objM = $scope.refundStateModel;
        if (objM != null) {
            $scope.getSourceConfig.refundState = objM.StateValue;
        } else {
            $scope.getSourceConfig.refundState = 0;
        }
        init();
    }
    //评价状态change事件  编辑
    $scope.AppraiseStateModelChange = function () {
        var objApp = $scope.appraiseStateModel;
        if (objApp!=null)
        {
            $scope.getSourceConfig.appraiseState = objApp.StateValue;
        } else {
            $scope.getSourceConfig.appraiseState = 0;
        }
        init();
    }

    //就诊状态change事件  编辑
    $scope.SurgeryStateModelChange = function () {
        var objApp = $scope.surgeryStateModel;
        if (objApp != null) {
            $scope.getSourceConfig.SurgeryState = objApp.StateValue;
        } else {
            $scope.getSourceConfig.SurgeryState = 0;
        }
        init();
    }

    //订单商品支付状态change事件  编辑
    $scope.PaymentStateChange = function () {
        var objApp = $scope.paymentStateMethod;
        if (objApp != null) {
            $scope.getSourceConfig.State = objApp.StateValue;
        } else {
            $scope.getSourceConfig.State = 0;
        }
        init();
    }
    

});


//项目查询 刘国全 2015-7-8 15:03:48
meb.controller('ProjectController', function ($scope, $http, Msg, paging, Verify) {

    //初始化服务
    $scope.pagingModel = paging;

    //获取数据时的配置
    $scope.getSourceConfig = { pageIndex: null, keyword: "", startTime: null, endTime: null };
    init();

    //页面初始化
    function init() {
        //获取列表数据
        getsortConfig = {
            method: 'GET',
            url: '/Project/GetJson?keyword=' + $scope.getSourceConfig.keyword + "&startTime=" + $scope.getSourceConfig.startTime + "&endTime=" + $scope.getSourceConfig.endTime + "&pageIndex" + $scope.getSourceConfig.pageIndex,
            data: {}//$scope.getSourceConfig
        }
        $http(getsortConfig).success(function (data) {
            $scope.model = data;
            $scope.ProjectAll = data.ProjectAll;
            if ($scope.model.PageList.Page != null) {
                //初始化分页
                $scope.pagingModel.init($scope.model.PageList.Page.PageIndex, $scope.model.PageList.Page.PageCount, $scope.model.PageList.Page.PageSize, $scope.model.PageList.Page.RecordCount, function (index) {
                    $scope.getSourceConfig.pageIndex = index;
                    init();
                });
            } else {
                $scope.pagingModel.paging = false;
            }
           
            //console.log($scope.pagingModel.list);
        }).error(function (data, status, headers, config) {
            $scope.editModel = false;
            $scope.changeModel = false;
            $scope.md.show('提示', '数据获取失败');
        });
    }


    //搜索事件
    $scope.search = function () {
        init();
    }


    //初始化模态窗
    $scope.md = Msg;
    $scope.changeModel = false; //移动商品
    $scope.editModel = false; //修改项目
    $scope.data = { ProjectsObj: null };  //模态窗口里面 属性必须先在外面声明
    //编辑数据
    $scope.editorData = {};//{ EditId: "", EditSequenceId: "", EditIsRecommend: "" }
    //移动数据
    $scope.changeData = {};


    $scope.editModelMsg = function (guid, SequenceId, IsRecommend) {
        //$scope.EditId = guid;
        //$scope.EditSequenceId = SequenceId;
        //$scope.EditIsRecommend = IsRecommend;

        $scope.editorData = { EditId: guid, EditSequenceId: SequenceId, EditIsRecommend: IsRecommend ? 1 : 0 }

        $scope.changeModel = false;
        $scope.editModel = true;
        Verify.initEdit('editmodel');
        $scope.md.okShow('编辑项目', '', function () {
            if (Verify.isPass('editmodel')) {
                //alert($scope.editorData.EditIsRecommend);
                var getsortConfig = {
                    method: 'Post',
                    url: '/Project/Edit',
                    data: {
                        id: $scope.editorData.EditId,
                        sequenceId: $scope.editorData.EditSequenceId,
                        isRecommend: $scope.editorData.EditIsRecommend == 1 ? true : false
                    }
                };
                $http(getsortConfig).success(function (data) {
                    if (data.ResultValue == 1) {
                        $scope.editModel = false;
                        $scope.md.show('提示', '编辑失败');
                    } else {
                        $scope.editModel = false;
                        $scope.md.show('提示', '编辑成功');
                        init();
                    }
                }).error(function (data, status, headers, config) {
                    $scope.md.show('提示', '编辑失败');
                });
            } else {
                $scope.md.showMe = false;
            }
            //$scope.md.showMe = false;  //关闭当前模态窗口
        });
    }
    $scope.OldId = "";
    $scope.oldName = "";
    $scope.changeModelMsg = function (guid, name, count) {
        if (count == 0) {
            $scope.editModel = false;
            $scope.changeModel = false;
            $scope.md.show('提示', '该项目下无商品');
        }
        else {
            $scope.changeData = { OldId: guid, OldName: name };

            $scope.changeModel = true;
            $scope.editModel = false;
            $scope.md.okShow('转移商品', '', function () {
                var getsortConfig = {
                    method: 'Post',
                    url: '/Project/Move',
                    data: {
                        id: guid,
                        newId: $scope.data.ProjectsObj.Id // 这里需要修改
                    }
                };
                $http(getsortConfig).success(function (data) {
                    if (data.ResultValue == 1) {
                        $scope.changeModel = false;
                        $scope.md.show('提示', '移动商品失败');
                    } else {
                        $scope.changeModel = false;
                        $scope.md.show('提示', '移动商品成功');
                        init();
                    }
                }).error(function (data, status, headers, config) {
                    $scope.changeModel = false;
                    $scope.md.show('提示', '移动失败');
                });
            });
        }

    }
});


//数据字典 刘国全 2015-7-9 12:05:40
meb.controller('StateInTableController', function ($scope, $http, Msg, paging,Verify) {

    //初始化模态窗
    $scope.md = Msg;
    $scope.AddModel = false; //移动商品
    $scope.EditModel = false; //修改项目


    //获取类别
    getsortConfig = {
        method: 'GET',
        url: '/StateInTable/GetStateColumnNameList',
        data: {}
    }
    $http(getsortConfig).success(function (data) {
        $scope.typeAll = data.Data;
        //$scope.typeAll = [{ "ColumnNote": "案例来源", "TableName": "Cases", "ColumnName": "SourceDevice", "IsBit": 0 }, { "ColumnNote": "案例审核状态", "TableName": "Cases", "ColumnName": "AuditStatus", "IsBit": 0 }, { "ColumnNote": "广告状态", "TableName": "Adverts", "ColumnName": "Status", "IsBit": 1 }];
    }).error(function (data, status, headers, config) {
        $scope.AddModel = false; //移动商品
        $scope.EditModel = false; //修改项目
        $scope.md.show('提示', '数据类别获取失败');
    });

    //---------------------------------分页开始---------------------------------
    //初始化服务
    $scope.pagingModel = paging;

    //获取数据时的配置 查询条件
    $scope.getSourceConfig = { page: null, tableName: null, columnNote: "" };
    //$scope.typeAllModel=null;
    init();
    //页面初始化
    function init() {
        if ($scope.getSourceConfig.tableName != null) {
            $scope.getSourceConfig.columnNote = $scope.getSourceConfig.tableName.ColumnNote;
        } else {
            $scope.getSourceConfig.columnNote = "";
        }

        //获取列表数据
        getsortConfig = {
            method: 'GET',
            url: '/StateInTable/GetPageList?page=' + $scope.getSourceConfig.page + "&columnNote=" + $scope.getSourceConfig.columnNote,
            data:{}// $scope.getSourceConfig
        }
        $http(getsortConfig).success(function (data) {
            //console.log(data);
            $scope.model = data;
            if ($scope.model.PageList.Page != null) {
                //初始化分页
                $scope.pagingModel.init($scope.model.PageList.Page.PageIndex, $scope.model.PageList.Page.PageCount, $scope.model.PageList.Page.PageSize, $scope.model.PageList.Page.RecordCount, function (index) {
                    $scope.getSourceConfig.page = index;
                    init();
                });
            }else{
                $scope.pagingModel.paging = false;
            }
           
        }).error(function (data, status, headers, config) {
            $scope.AddModel = false; //移动商品
            $scope.EditModel = false; //修改项目
            $scope.md.show('提示', '数据获取失败');
        });
        
    }
    //---------------------------------分页结束---------------------------------
    //搜索事件
    $scope.search = function () {
        init();
    }



    //类别数据源
    $scope.data = { StateColumnNames: null };  //模态窗口里面 属性必须先在外面声明  
    $scope.isBitShow = false;  
    //需要编辑的数据
    $scope.editorData = { Id: "", TableName: "", ColumnName: "", ColumnNote: "", StateValue: null, StateName: null, BitValue: null, BitName: null };
    //需要新增的数据
    $scope.addData = { TableName: "", ColumnName: "", ColumnNote: "", StateValue: null, StateName: null, BitValue: null, BitName: null };

    $scope.AddModelMsg = function () {
        $scope.EditModel = false;
        $scope.AddModel = true;
        $scope.addData.BitValue = 1;
        Verify.init('addmodel');
        $scope.md.okShow('新增字典', '', function () {
            var stateObj = $scope.data.StateColumnNames;
            if (stateObj == null) {
                $("[name='statecolumnnames']").attr("data-show", "true");
            }
           
            //if (Verify() && $("[name='statecolumnnames']").attr("data-show") == "false") {
            if (Verify.isPass('addmodel')) {
                //alert($scope.data.StateColumnNames.ColumnNote);
                $scope.addData.TableName = stateObj.TableName,
                $scope.addData.ColumnName = stateObj.ColumnName;
                $scope.addData.ColumnNote = stateObj.ColumnNote;
                $scope.addData.BitValue = $scope.addData.BitValue == "0" ? 0 : 1;
                if (stateObj.IsBit == 1) {
                    $scope.addData.StateValue = null;
                    $scope.addData.StateName = null;
                } else {
                    $scope.addData.BitValue = null;
                    $scope.addData.BitName = null;
                }
                console.log("新增字典" + $scope.addData);
                var getsortConfig = {
                    method: 'Post',
                    url: '/StateInTable/Create',
                    data: $scope.addData
                };
                $http(getsortConfig).success(function (data) {
                    if (data.ResultValue == 1) {
                        $scope.AddModel = false;  //关闭当前模态窗口
                        $scope.md.show('提示', '新增失败');
                    } else {
                        $scope.AddModel = false; //关闭当前模态窗口
                        $scope.md.show('提示', '新增成功');
                        $scope.addData.StateValue = "";
                        $scope.addData.StateName = "";
                        $scope.addData.BitName = "";
                        init();
                    }
                }).error(function (data, status, headers, config) {
                    $scope.AddModel = false;  //关闭当前模态窗口
                    $scope.md.show('提示', '新增失败');
                });

            } else {
                $scope.md.showMe = false;
            }
        
        });
    }

    $scope.EditModelMsg = function (guid) {

        //获取修改的数据 
        var getsortConfig = {
            method: 'Post',
            url: '/StateInTable/GetList',
            data: { id: guid }
        };
        $http(getsortConfig).success(function (data) {
            if (data.ResultValue == 1) {
                $scope.md.show('提示', '数据获取失败');
                return;
            }
            //console.log(data);
            $scope.editorData = data.Data;  //绑定数据
            $scope.isBitShow = $scope.editorData.StateValue == null ? false : true;
            $scope.data.StateColumnNames = data.Data.ColumnNote;  //这种默认值
            

        }).error(function (data, status, headers, config) {
          $scope.EditModel = false;
          $scope.AddModel = false;
          $scope.md.show('提示', '数据获取失败');
        });

        $scope.EditModel = true;
        $scope.AddModel = false;
        Verify.initEdit('editmodel');
        $scope.md.okShow('修改字典', '', function () {
            debugger;
            var columnNote = $scope.data.StateColumnNames;
            var typeAllObj = $scope.typeAll;
            var stateObj = null;

            angular.forEach(typeAllObj, function (data, index, array) {
                if (stateObj == null && columnNote == data.ColumnNote) {
                    stateObj = data;
                }
                //console.log(data.ColumnNote);
            });

            if (stateObj == null) {
                $("[name='editstatecolumnnames']").attr("data-show", "true");
            }
      
            if (Verify.isPass('editmodel')) {
                var columnNote = $scope.data.StateColumnNames;
                var typeAllObj = $scope.typeAll;
        
                if (stateObj == null) {
                    $scope.md.show('提示', '修改失败');
                }

                $scope.editorData.TableName = stateObj.TableName,
                $scope.editorData.ColumnName = stateObj.ColumnName;
                $scope.editorData.ColumnNote = stateObj.ColumnNote;
                $scope.editorData.BitValue = $scope.editorData.BitValue == "0" ? 0 : 1;

                if (stateObj.IsBit == 1) {
                    $scope.editorData.StateValue = null;
                    $scope.editorData.StateName = null;
                } else {
                    $scope.editorData.BitValue = null;
                    $scope.editorData.BitName = null;
                }

                var getsortConfig = {
                    method: 'Post',
                    url: '/StateInTable/Modify',
                    data: $scope.editorData
                };
                $http(getsortConfig).success(function (data) {
                    if (data.ResultValue == 1) {
                        $scope.EditModel = false;  //关闭当前模态窗口
                        $scope.md.show('提示', '修改失败');
                    } else {
                        $scope.EditModel = false;  //关闭当前模态窗口
                        $scope.md.show('提示', '修改成功');
                        $scope.editorData.StateValue = "";
                        $scope.editorData.StateName = "";
                        $scope.editorData.BitName = "";
                        init();
                    }
                }).error(function (data, status, headers, config) {
                    $scope.md.show('提示', '修改失败');
                });
            } else {
                $scope.md.showMe = false;
            }
          
        });
    }

    //删除类别
    $scope.Delete = function (id) {
        $scope.EditModel = false;
        $scope.AddModel = false;

        $scope.md.close = '否';
        $scope.md.okText = '是';
        $scope.md.okShow('确认兑换框', '是否确定删除，删除后不可恢复！', function () {
            getsortConfig = {
                method: 'POST',
                url: '/StateInTable/Delete',
                data: {
                    Id: id
                }
            }
            $http(getsortConfig).success(function (data) {

                if (data.ResultValue == 1) {
                    $scope.EditModel = false;
                    $scope.md.close = '关闭';
                    $scope.md.okText = '确定';
                    $scope.md.show('提示', '删除失败');
                } else {
                    $scope.EditModel = false;
                    $scope.md.close = '关闭';
                    $scope.md.okText = '确定';
                    $scope.md.show('提示', '删除成功');
                    init();
                }
            }).error(function (data, status, headers, config) {
                $scope.md.close = '关闭';
                $scope.md.okText = '确定';
                $scope.md.show('提示', '删除失败');
            });
            $scope.md.close = '关闭';
            $scope.md.okText = '确定';
        });
    }

    //类别change事件 新增
    $scope.StateColumnNamesChange = function () {
        var stateObj = $scope.data.StateColumnNames;
        if (stateObj!=null)
        {
            $("[name='statecolumnnames']").attr("data-show", "false");
            $scope.isBitShow = !stateObj.IsBit;
            var divObj = $("[ng-show='AddModel']");
            divObj.find("span[data-addmodel-statevalue]").attr("data-show", "false");
            divObj.find("span[data-addmodel-statename]").attr("data-show", "false");
            divObj.find("span[data-addmodel-bitname]").attr("data-show", "false");
        } else {
            $("[name='statecolumnnames']").attr("data-show", "true");
        }
    }

    //类别change事件  编辑
    $scope.EditStateColumnNamesChange = function () {
        var columnNote = $scope.data.StateColumnNames;
        var stateObj = null;
        var typeAllObj = $scope.typeAll;

        angular.forEach(typeAllObj, function (data, index, array) {
            if (stateObj == null && columnNote == data.ColumnNote) {
                stateObj = data;
            }
            //console.log(data.ColumnNote);
        });
       
        if (stateObj!=null)
        {
            $("[name='editstatecolumnnames']").attr("data-show", "false");
            $scope.isBitShow = !stateObj.IsBit;
            if (stateObj.IsBit) {
                var divObj = $("div[ng-show*='EditModel']");
                divObj.find("[name='statevalue']").removeAttr("verify").removeAttr("empty");
                divObj.find("[name='statename']").removeAttr("verify").removeAttr("empty");
                divObj.find("[name='bitname']").attr("verify", "false").removeAttr("empty");
                //bit
            } else {
                var divObj = $("[ng-show='AddModel']");

                divObj.find("[name='statevalue']").attr("verify", "false").removeAttr("empty");
                divObj.find("[name='statename']").attr("verify", "false").removeAttr("empty");
                divObj.find("[name='bitname']").removeAttr("verify").removeAttr("empty");
            }
        } else {
            $("[name='editstatecolumnnames']").attr("data-show", "true");
        }
 
    }

    //类别change事件 查询
    $scope.TableNameChange = function () {
        init();
    }
});

//返款查询 刘国全 2015-7-16 19:48:53
meb.controller('BackIndexController', function ($scope, $http, Msg, paging) {
    //获取支付方式
    getsortConfig = {
        method: 'GET',
        url: '/ProductPayment/GetStateInTablesModel?columnNote=1',
        data: {}
    }
    $http(getsortConfig).success(function (data) {
        $scope.paymentMethodAll = data.Data;
        //console.log($scope.model.PageList.Page.RecordCount);
    }).error(function (data, status, headers, config) {
        $scope.md.show('提示', '数据获取失败');
    });

    //---------------------------------分页开始---------------------------------
    //初始化服务
    $scope.pagingModel = paging;

    //获取数据时的配置 查询条件
    $scope.getSourceConfig = { PageIndex: null, ProductOrderNumbe: "", Name: "", ProductNumber: "", PaymentMethod: 0, OrderStatus: null, CashbackAwaiting: null, StartCreateTime: null, EndCreateTime: null, StartUpdateTime: null, EndUpdateTime: null, CashbackOrRefund: 2, deliverState: 0, appraiseState: 0, refundState: 0,AuditStatus:6};
    //$scope.typeAllModel=null;
    init();
    //页面初始化
    function init() {
        //获取列表数据
        getsortConfig = {
            method: 'Post',
            url: '/ProductPayment/GetBackJson',
            data: $scope.getSourceConfig
        }
        $http(getsortConfig).success(function (data) {
            $scope.model = data;
            if ($scope.model.PageList.Page != null) {
                //初始化分页
                $scope.pagingModel.init($scope.model.PageList.Page.PageIndex, $scope.model.PageList.Page.PageCount, $scope.model.PageList.Page.PageSize, $scope.model.PageList.Page.RecordCount, function (index) {
                    $scope.getSourceConfig.PageIndex = index;
                    init();
                });
            }else{
                $scope.pagingModel.paging = false;
            }
       
        }).error(function (data, status, headers, config) {
            $scope.BackModel = false;
            $scope.md.show('提示', '数据获取失败');
        });

    }
    //---------------------------------分页结束---------------------------------

    //搜索事件
    $scope.search = function () {
        init();
    }

    //支付change事件  编辑
    $scope.PaymentMethodChange = function () {
        var objM = $scope.PaymentMethod;
        if (objM != null) {
            $scope.getSourceConfig.PaymentMethod = objM.StateValue;
        }
        //alert($scope.getSourceConfig.PaymentMethod);
        init();
    }
});


//退款查询 刘国全 2015-7-17 13:51:11
meb.controller('RefundIndexController', function ($scope, $http, Msg, paging) {
    //获取支付方式
    getsortConfig = {
        method: 'GET',
        url: '/ProductPayment/GetStateInTablesModel?columnNote=1',
        data: {}
    }
    $http(getsortConfig).success(function (data) {
        $scope.paymentMethodAll = data.Data;
        //console.log($scope.model.PageList.Page.RecordCount);
    }).error(function (data, status, headers, config) {
        $scope.md.show('提示', '数据获取失败');
    });

    //---------------------------------分页开始---------------------------------
    //初始化服务
    $scope.pagingModel = paging;

    //获取数据时的配置 查询条件
    // CashbackOrRefund: 1 表示 退款 
    // AuditStatus: 3  表示  已退款
    $scope.getSourceConfig = { PageIndex: null, ProductOrderNumbe: "", Name: "", ProductNumber: "", PaymentMethod: 0, OrderStatus: null, CashbackAwaiting: null, StartCreateTime: null, EndCreateTime: null, StartUpdateTime: null, EndUpdateTime: null, CashbackOrRefund: 1, deliverState: 0, appraiseState: 0, refundState: 0, AuditStatus: 3 };
    //$scope.typeAllModel=null;
    init();
    //页面初始化
    function init() {
        //获取列表数据
        getsortConfig = {
            method: 'Post',
            url: '/ProductPayment/GetRefundJson',
            data: $scope.getSourceConfig
        }
        console.log($scope.getSourceConfig.EndCreateTime);
        $http(getsortConfig).success(function (data) {
            $scope.model = data;
            if ($scope.model.PageList.Page != null) {
                //初始化分页
                $scope.pagingModel.init($scope.model.PageList.Page.PageIndex, $scope.model.PageList.Page.PageCount, $scope.model.PageList.Page.PageSize, $scope.model.PageList.Page.RecordCount, function (index) {
                    $scope.getSourceConfig.PageIndex = index;
                    init();
                });
            } else {
                $scope.pagingModel.paging = false;
            }
           
        }).error(function (data, status, headers, config) {
            $scope.BackModel = false;
            $scope.md.show('提示', '数据获取失败');
        });

    }
    //---------------------------------分页结束---------------------------------

    //搜索事件
    $scope.search = function () {
        init();
    }

    //支付change事件  编辑
    $scope.PaymentMethodChange = function () {
        var objM = $scope.PaymentMethod;
        if (objM != null) {
            $scope.getSourceConfig.PaymentMethod = objM.StateValue;
        }
        //alert($scope.getSourceConfig.PaymentMethod);
        init();
    }
});